package com.guoxin.part1.chapter3;

import java.util.concurrent.TimeUnit;

/**
 * 线程interrupt
 *
 * @author guoxin
 * @date 2019/8/27
 */
public class ThreadInterrupt {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                System.out.println(Thread.currentThread().getName() + " 线程被打断了");
            }
        });

        thread.start();
        TimeUnit.MILLISECONDS.sleep(2);
        thread.interrupt();
    }
}
